#!/usr/bin/perl


use strict;
use Data::Dumper;
use lib 'Qverst/lib/';
use lib 'CSS-Builder/lib/';

use Time::HiRes qw( gettimeofday tv_interval );

my $t0 = [gettimeofday];


use CSS;
my $css = CSS->new( { 'parser' => 'CSS::Parse::AsBuilder' } );

$css->read_file( 'main.css' );



use CSS::Optimize;
use CSS::Utils::Walk;

my $optimize = CSS::Optimize->new(
    tree => $css->document
);

$optimize->simple;

print $css->output;

#my $walk = CSS::Utils::Walk->new(
#    tree => $css->document
#);

#my @d = $walk->walk(
#    sub {
#         my $tree = shift;
#         return $tree->id;
#    }
#);




#print Dumper \@d;


if ($#ARGV > 0) {
      print Dumper $css;
} else {
      print "Generation time: " , tv_interval ( $t0, [gettimeofday]) , "\n";
}